package com.tang.algorithm.eliminationStrategy;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/5/2 21:30
 */
public class LRU<K,V>  extends LinkedHashMap<K,V> {
    private final int CACHE_SIZE;

    public LRU(int cacheSize) {
        super((int)Math.ceil((cacheSize/0.75)+1),0.75f,true);
        CACHE_SIZE = cacheSize;
    }
    @Override
    protected boolean removeEldestEntry(Map.Entry<K,V> eldest){
        return size()>CACHE_SIZE;
    }
}
